package cn.kennylee.codehub.mq.lip.integration.rocketmq;

import lombok.Getter;
import lombok.Setter;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.boot.context.properties.NestedConfigurationProperty;

import java.time.Duration;
import java.util.List;

/**
 * <p> RocketMQ配置属性类 </p>
 * <p>Created on 2025/5/24.</p>
 *
 * @author kennylee
 * @since 0.0.1
 */
@Getter
@Setter
@ConfigurationProperties(prefix = "app.rocketmq")
public class RocketMqConfigProperties {

    /**
     * 消息队列延迟配置
     */
    @NestedConfigurationProperty
    private Delay delay = new Delay();

    @Getter
    @Setter
    public static class Delay {
        /**
         * <p>延迟级别</p>
         * <p>RocketMQ支持的延迟级别，单位为秒或分钟</p>
         * <p>注意：RocketMQ 4.x 的延迟级别是固定的，不能自定义，这些等级在 Broker 的配置文件 broker.conf 中通过 messageDelayLevel 参数进行配置</p>
         * <p>默认级别为1s, 5s, 10s, 30s, 1m, 2m, 3m, 4m, 5m, 6m, 7m, 8m, 9m, 10m, 20m, 30m, 1h, 2h</p>
         */
        private List<Duration> levels = List.of(
            Duration.ofSeconds(1), // 1s
            Duration.ofSeconds(5), // 5s
            Duration.ofSeconds(10), // 10s
            Duration.ofSeconds(30), // 30s
            Duration.ofMinutes(1), // 1m
            Duration.ofMinutes(2), // 2m
            Duration.ofMinutes(3), // 3m
            Duration.ofMinutes(4), // 4m
            Duration.ofMinutes(5), // 5m
            Duration.ofMinutes(6), // 6m
            Duration.ofMinutes(7), // 7m
            Duration.ofMinutes(8), // 8m
            Duration.ofMinutes(9), // 9m
            Duration.ofMinutes(10), // 10m
            Duration.ofMinutes(20), // 20m
            Duration.ofMinutes(30), // 30m
            Duration.ofHours(1), // 1h
            Duration.ofHours(2) // 2h
        );
    }
}
